<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>下单奖励提成新增 - 766 SMART HOME</title>
<meta name="author" content="BIZ Team" />
<meta name="copyright" content="BIZ" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div class="path">
		<a href="${base}/admin/common/index.jhtml">${message("admin.path.index")}</a> &raquo; 新增
	</div>
	<form id="inputForm" action="save.jhtml" method="post">
		<ul id="tab" class="tab">
			<li>
				<input type="button" value="${message("admin.product.base")}" />
			</li>
		</ul>
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField">*</span>类型:
				</th>
				<td>
					<select name="type" class="option">
						<option value="1">单体商品</option>
						<option value="2">方案</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>分类:
				</th>
				<td>
					<select name="category" class="option">
						<option value="">请选择</option>
						[#list productCategorys as pc]
							<option value="${pc.id}">${pc.name}</option>
						[/#list]
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>品牌:
				</th>
				<td>
					<select name="brand" class="option">
						<option value="">请选择</option>
						[#list brands as brand]
							<option value="${brand.id}">${brand.name}</option>
						[/#list]
					</select>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>提成点(%):
				</th>
				<td>
					<input type="text" name="point" class="text" maxlength="5" />
				</td>
			</tr>
		</table>
		<table class="input">
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="保存" />
					<input type="button" class="button" value="返回" onclick="window.location.href='list.jhtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<script type="text/javascript">
$().ready(function() {
	
	[@flash_message /]
	
	var $inputForm = $("#inputForm");
	var $type = $("select[name='type']")
	var $category = $("select[name='category']")
	var $productCategorysData = ${productCategorysData};
	var $schemeCategorysData = ${schemeCategorysData};
	
	// 表单验证
	$inputForm.validate({
		rules: {
			type: "required",
			category:"required",
			brand: "required",
			point: {
				required: true,
				pattern:/^(?!00)(?!0.$)(?!0.0$)(?!0.00$)[0-9]+[.]?[0-9]{0,2}$/,
				maxlength:5,
				minlength:1
			}
		},
		messages: {
			type: {
				required: "${message("admin.validate.required")}",
			},
			category: {
				required: "${message("admin.validate.required")}",
			},
			brand: {
				required: "${message("admin.validate.required")}",
			},
			point: {
				required: "${message("admin.validate.required")}",
				pattern:"格式有误"
			}
		},
	});
	
	//根据类型查询分类
	$type.change(function(){
		var type = $type.val();
		var htm = "";
		$category.empty();
		$category.append("<option value=''>请选择</option>");
		if(type == 1){
			for(var i= 0 ;i < $productCategorysData.length;i++){
				var data = $productCategorysData[i];
				htm += "<option value='"+data.id+"'>"+data.name+"</option>";
			}
		}else if(type == 2){
			for(var i= 0 ;i < $schemeCategorysData.length;i++){
				var data = $schemeCategorysData[i];
				htm += "<option value='"+data.id+"'>"+data.title+"</option>";
			}
		}
		$category.append(htm);
	});
	
});
</script>